<?php

namespace app\common\model;

use ShidianUtil\Thinkphp\Relation\MorphTo;

/**
 * Class ConsultingMessage
 * @package app\model
 * @property int $id
 * @property int $consultingId
 * @property int $senderType
 * @property int $senderMemberType
 * @property int $senderId
 * @property int $receiveId
 * @property string $messageType
 * @property \stdClass $content
 * @property int $messageTime
 * @property int $isDel
 * @property int $updated
 * @property int $created
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037579
 * @link https://www.kancloud.cn/manual/think-orm/1257998
 * @link https://www.kancloud.cn/thinkphp/master-database-and-model/265551
 */
class ConsultingMessage extends \app\common\model\BaseModel
{
    // 消息类型
    // text纯文本 post富文本 image图片 audio音频 media视频 file文件 server咨询服务推荐 lawyer律师名片 lawyers律师接单推荐
    // system系统消息 comment评价 reward悬赏 redpacket红包 phone电话号码 progress进度卡片 platform平台卡片 text_rotational带轮播文字的消息
    // text_remarks带绿色备注的文本消息
    const TEXT = 'text';
    const IMAGE = 'image';
    const SERVER = 'server';
    const LAWYER = 'lawyer';
    const LAWYERS = 'lawyers';
    const SYSTEM = 'system';
    const COMMENT = 'comment';
    const REWARD = 'reward';
    const REDPACKET = 'redpacket';
    const PHONE = 'phone';
    const PROGRESS = 'progress';
    const PLATFORM_CARD = 'platform';
    const TEXT_ROTATIONAL = 'text_rotational';
    const TEXT_REMARKS = 'text_remarks';



    protected $name = 'ConsultingMessage';

    // 设置json类型字段
    protected $json = ['content'];

    public function sender()
    {
        $alias = [
            'member' => Member::class,
            'robot' => Robot::class,
            'system' => Robot::class,
        ];
        return new MorphTo($this, 'senderType', 'senderId', $alias, 'sender');
    }

    /**
     * 1对1
     * @return \think\model\relation\HasOne
     */
    //    public function one(){
    //        return $this->hasOne( Test1::class, 'Test1表中的键', 'ConsultingMessage表中的键');
    //    }

    /**
     * 1对多
     * @return \think\model\relation\HasMany
     */
    //    public function many(){
    //        return $this->hasMany( Test1::class, 'Test1表中的键', 'ConsultingMessage表中的键');
    //    }

    /**
     * 多对多
     * @return \think\model\relation\BelongsToMany
     */
    //    public function belongs(){
    //        return $this->belongsToMany( Test1::class, '中间表', '中间表中Test1的键', '中间表中ConsultingMessage的键');
    //    }
}
